Skip to main content

Jenkins Integration Guide

This guide outlines the steps to integrate your project with Jenkins using pipelines. Jenkins pipelines automate the build, test, and deployment process, providing a structured way to manage your project's lifecycle.

Prerequisites

  • A Jenkins instance set up and running.
  • Access to your project's source code repository.
  • The following tools installed on your Jenkins server:
    • jq: A lightweight and flexible command-line JSON processor. You can install it by following the instructions at jq installation guide.
    • curl: A command-line tool to transfer data to or from a server using various protocols. You can install it by following the instructions at curl download page.
  • Configure the necessary environment variables such as path in Jenkins settings that your pipeline might need during the build process.

Steps

Step 1: Setting Up a New Pipeline

  1. Open the **Jenkins Admin ** dashboard.
  2. Click on create a new item.
  3. Choose pipeline as the project type and give it a meaningful name.
  4. Trigger the job to ensure that the pipeline folder is created.

Step 2: Configuring Pipeline Options

  1. After creating the pipeline, navigate to its configuration.

  2. Without Source Code Management

    1. Select definition as pipeline script.
    2. Copy the sample Jenkinsfile to script editor.
  3. With Source Code Management

    1. Select definition as pipeline script from SCM.
    2. Select SCM as git.
    3. Enter Repository URL and Credentials in Repositories section.
    4. Make sure to have Jenkinsfile in the root directory of the repository.

Step 3: Handling the Execution Script

  1. Update api key in environement section of Jenkinsfile script with

    sample_api_integration_key
  2. Download the execute.sh file and place it in the appropriate location:

    • For projects without Source Code Management, place it in pathToJenkinsWorkspace/pipelineName.
    • For projects with Source Code Management, place it in the repository.
  3. Grant execute permission to the execute.sh file.

  4. Update first step in Run Test Script stage of Jenkinsfile as sh 'pathToJenkinsWorkspace/pipelineName/execute.sh -t ${API_KEY}' where pathToJenkinsWorkspace is jenkins workspace directory and pipelineName is the name of the pipeline. e.g sh '/home/root/.jenkins/workspace/test_pipeline/execute.sh -t ${API_KEY}'

  5. Update the placeholder PLACE_YOUR_CURL_COMMAND_HERE with your actual curl command:

    curl --location false/v2/apikeyexecution \
      --header "Content-Type: application/json" \
      --header "api-key: sample_api_integration_key" \
      --data '{
        "projectId": "PROJECT_ID",
        "organizationId": "ORGANIZATION_ID",
        "scenarioIds": ["SCENARIO_ID1", "SCENARIO_ID2"],
        "config": {
          "browser": { "id": "chrome", "label": "Chrome" },
          "environmentId": "ENV_ID",
          "os": { "id": "ubuntu", "label": "Ubuntu" },
          "resolution": { "id": "1", "label": "Ultra-Wide 4K (3840×2160)" }
        }
      }'

    in execute.sh file on line no. 71.

Step 4: Finalizing Configuration

  1. Save the pipeline configuration.
  2. Trigger a build by clicking on Build Now.